package com.hpin.fansea.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.hpin.fansea.R;

import java.util.List;

/**
 * Created by Aaron on 15/9/21.
 */
public class MyRoomNumberAdapter extends BaseAdapter {

    private List<String> list;
    private Context context;

    public MyRoomNumberAdapter(List<String> list, Context context) {
        super();
        this.list = list;
        this.context = context;
    }

    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public Object getItem(int position) {
        return list.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {

        ViewHolder holder = null;
        if (convertView == null) {

            convertView = View.inflate(context, R.layout.item_my_roomnumber, null);
            holder = new ViewHolder();
            holder.room_number = (TextView) convertView.findViewById(R.id.roomnumber_item);
            convertView.setTag(holder);

        }else {
            holder = (ViewHolder) convertView.getTag();
        }
        holder.room_number.setText(list.get(position));
        return convertView;
    }

    class ViewHolder {
        TextView room_number;
    }

}
